home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / Lex.cpt / Lex / LEXLIB.π folder / INTEG.C < prev    next >
Text File  |  1990-04-22  |  912b  |  40 lines

  1. /*
  2.   HEADER: CUG    nnn.nn;
  3.   TITLE:    LEX - A Lexical Analyser Generator
  4.   VERSION:       1.0 for IBM-PC
  5.   DATE:    Jan 30, 1985
  6.   DESCRIPTION:   A Lexical Analyser Generator. From UNIX
  7.   KEYWORDS:      Lexical Analyser Generator YACC C PREP
  8.   SYSTEM:    IBM-PC and Compatiables
  9.   FILENAME:      INTEG.C
  10.   WARNINGS:      This program is not for the casual user. It will
  11.     be useful primarily to expert developers.
  12.   CRC:    N/A
  13.   SEE-ALSO:      YACC and PREP
  14.   AUTHORS:       Scott Guthery 11100 leafwood lane Austin, TX 78750
  15.   COMPILERS:     DESMET-C
  16.   REFERENCES:    UNIX Systems Manuals
  17. */
  18. #include    "lex.h"
  19. /*
  20.  * integ -- ascii to long (various bases)
  21.  */
  22. long
  23. integ(char *cp, register int base)
  24. {
  25.     register c;
  26.     long n;
  27.  
  28.     n = 0;
  29.     while (c = *cp++) {
  30.         if (c>='A' && c<='Z')
  31.             c += 'a'-'A';
  32.         if (c>='a' && c<='z')
  33.             c = (c-'a')+10+'0';
  34.         if (c < '0' || c > base+'0')
  35.             break;
  36.         n = n*base + c-'0';
  37.         }
  38.     return(n);
  39. }
  40.